Skip to main content

AU2340264_Saumya_Dhaivat_Dholakia

Submission at 2024-08-09 04:48:06

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
System.out.println("Enter name");
a=sd.nextLine();
System.out.println("Hello "+a+"!");
}
}

Submission at 2024-08-09 04:49:00

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
a=sd.nextLine();
System.out.println("Hello "+a+"!");
}
}

Submission at 2024-08-09 04:52:15

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
a=sd.nextLine();
if(1<=a.length&&a.length<=100)
System.out.println("Hello "+a+"!");
}
}

Submission at 2024-08-09 04:52:56

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
a=sd.nextLine();
if(1<=a.length&&a.length<=100){
System.out.println("Hello "+a+"!");
}

}
}

Submission at 2024-08-09 04:53:35

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
a=sd.nextLine();
if(1<=a.length&&a.length<=100){
System.out.println("Hello "+a+"!");
}

}
}

Submission at 2024-08-09 04:54:26

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
a=sd.nextLine();
if(1<=a.length&&a.length<=100){
System.out.println("Hello "+a+"!");
}
else{
System.out.println("Out of size");
}

}
}

Submission at 2024-08-09 04:55:26

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String a;
a=sd.nextLine();
if(1<=a.length()&&a.length()<=100){
System.out.println("Hello "+a+"!");
}
else{
System.out.println("Out of size");
}

}
}

Submission at 2024-08-09 05:06:23

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.nextLine();
if(name.length()>=1&&name.length()<=100){
System.out.println(name);
}
else{
System.out.println("Out of range");
}
}
}
}
}

Submission at 2024-08-09 05:11:12

// Write your Java code here from the scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String n=sd.nextLine();
if(n.length()>=1&&n.length()<=100){
System.out.println("Hello "+n+"!");
}
else{
System.out.println("Out of range");
}
}
}

Submission at 2024-08-09 05:20:45

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.nextLine();
if(name.length()>=1 && name.length()<=100){
System.out.println(name);
}
else{
System.out.println("out of range1");
}
}
}
else{
System.out.println("out of range");
}
}
}

Submission at 2024-08-09 05:21:01

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.nextLine();
if(name.length()>=1 && name.length()<=100){
System.out.println("Hello"+name+"!");
}
else{
System.out.println("out of range1");
}
}
}
else{
System.out.println("out of range");
}
}
}

Submission at 2024-08-09 05:21:05

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.nextLine();
if(name.length()>=1 && name.length()<=100){
System.out.println("Hello"+name+"!");
}
else{
System.out.println("out of range1");
}
}
}
else{
System.out.println("out of range");
}
}
}

Submission at 2024-08-09 05:21:42

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.nextLine();
if(name.length()>=1 && name.length()<=100){
System.out.println("Hello "+name+"!");
}
else{
System.out.println("out of range1");
}
}
}
else{
System.out.println("out of range");
}
}
}

Submission at 2024-08-09 05:22:52

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.nextLine();
if(name.length()>=1 && name.length()<=100){
System.out.println("Hello "+name+"!");
}
else{
System.out.println("out of range");
}
}
}
else{
System.out.println("out of range");
}
}
}

Submission at 2024-08-09 05:24:00

// Write your Java code here
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
if(n>=1&&n<=100){
for(int i=1;i<=n;i++){
String name=sd.next();
if(name.length()>=1 && name.length()<=100){
System.out.println("Hello "+name+"!");
}
else{
System.out.println("out of range");
}
}
}
else{
System.out.println("out of range");
}
}
}

Submission at 2024-08-21 08:00:53

#include <iostream>

using namespace std;

int fibonacci(int x) {
// write your code here
if(x==1){
return 1;
}
if(x==0){
return 0;
}
return fibonacci(x-1)+fibonacci(x-2);
}

int main() {
int x;
cin >> x;

// Calculate and print the Fibonacci number for the input x
cout << fibonacci(x) << endl;

return 0;
}

Submission at 2024-08-21 08:02:49

#include <iostream>

using namespace std;

int fibonacci(int x) {
// write your code here
if(x==1){
return 1;
}
if(x==0){
return 0;
}
return fibonacci(x-1)+fibonacci(x-2);
}

int main() {
int x;
cin >> x;

// Calculate and print the Fibonacci number for the input x
cout << fibonacci(x) << endl;

return 0;
}

Submission at 2024-08-21 08:05:48

#include <iostream>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
if(n%2==0){
return true;
}
else{
return false;
}
}

int main() {
int n;
cin >> n;

// Determine if n is a power of two
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;

return 0;
}

Submission at 2024-08-21 08:27:38

#include <iostream>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;

// Determine if n is a power of two
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;

return 0;
}

Submission at 2024-08-21 08:31:51

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<=pow(2,31)-1 && n>=pow(-2,31)){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else{
cout<<"Wrong integer input";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:33:57

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<=pow(2,31)-1 && n>=pow(-2,31)){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
if(n==1 || n==0){
cout << false << endl;
}
else{
cout<<"Wrong integer input";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:35:10

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<=pow(2,31)-1 && n>=pow(-2,31) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
if(n==1 || n==0){
cout << false << endl;
}
else{
cout<<false;
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:37:10

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << false << endl;
}
else{
cout<<false;
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:38:27

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && (m==1 || m==-1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << false << endl;
}
else{
cout<<false;
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:40:19

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && (m==1 || m==-1)){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << false << endl;
}
else{
cout<<false;
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:43:37

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<0){
n=-n;
}
if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << false << endl;
}
else{
cout<<false;
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:45:24

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;
if(n<0){
n=-n;
}
if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << "false" << endl;
}
else{
cout<<"false";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:46:22

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;

if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << "false" << endl;
}
else{
cout<<"false";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:48:21

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;

if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==1 || n==0){
cout << "false" << endl;
}
else{
cout<<"false";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:49:41

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;

if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==0){
cout << "false" << endl;
}
else{
cout<<"false";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-21 08:51:27

#include <iostream>
#include<math.h>

using namespace std;

bool isPowerOfTwo(int n) {
// Write your logic here
int m=n/2;
int h=n%2;
if(h==0 && m==1){
return true;
}
if(h!=0){
return false;
}
return isPowerOfTwo(m+h);
}

int main() {
int n;
cin >> n;

if(n<=(pow(2,31)-1) && n>=(pow(-2,31)) && n!=1 && n!=0 ){
cout << (isPowerOfTwo(n) ? "true" : "false") << endl;
}
else if(n==0){
cout << "false" << endl;
}
else if(n==1){
cout << "true" << endl;
}
else{
cout<<"false";
}
// Determine if n is a power of two


return 0;
}

Submission at 2024-08-22 12:33:36

import java.util.*;
import java.io.*;

class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().trim().split("\\s+");
int n = Integer.parseInt(input[0]);
int k = Integer.parseInt(input[1]);

// Generate combinations
List<List<Integer>> result = combine(n, k);

// Sort subsets based on size and uncommon element
Collections.sort(result, new Comparator<List<Integer>>() {
@Override
public int compare(List<Integer> a, List<Integer> b) {
// Compare based on size first if sizes are different
if (a.size() != b.size()) {
return Integer.compare(a.size(), b.size());
}

// Sizes are the same, compare elements one by one
for (int i = 0; i < a.size(); i++) {
int comparison = Integer.compare(a.get(i), b.get(i));
if (comparison != 0) {
return comparison;
}
}

// If all elements are equal, return 0 (indicating they are considered equal)
return 0;
}
});

// Print combinations
System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("[");
for (int j = 0; j < result.get(i).size(); j++) {
System.out.print(result.get(i).get(j));
if (j < result.get(i).size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<List<Integer>> combine(int n, int k) {
// write logic here
List<List<Integer>> result=new ArrayList<>();
backtrack(1, new ArrayList<>(),result,n,k);
return result;
}

private static void backtrack(int start, List<Integer> comb, List<List<Integer>> res, int n, int k) {
// use it if you want
if(comb.size()==k){
res.add(new ArrayList<>(comb));
return ;
}
for(int i=start;i<=n;i++){
comb.add(i);
backtrack(i+1, comb, res, n, k);
comb.remove(comb.size()-1);
}
}
}

Submission at 2024-08-22 12:47:22

import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine().trim());

List<String> result = genParen(n);

System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("\"" + result.get(i) + "\"");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<String> genParen(int n) {
List<String> result = new ArrayList<>();
backtrack(result, "", 0, 0, n);
return result;
}

private static void backtrack(List<String> result, String current, int open, int close, int max) {

if (current.length() == max * 2) {
result.add(current);
return;
}

if (open < max) {
backtrack(result, current + "(", open + 1, close, max);
}

if (close < open) {
backtrack(result, current + ")", open, close + 1, max);
}
}
}

Submission at 2024-08-22 12:51:02

import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine().trim());

List<String> result = genParen(n);

System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("\"" + result.get(i) + "\"");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<String> genParen(int n) {
List<String> result = new ArrayList<>();
backtrack(result, "", 0, 0, n);
return result;
}

private static void backtrack(List<String> result, String current, int open, int close, int max) {

if (current.length() == max * 2) {
result.add(current);
return;
}

if (open < max) {
backtrack(result, current + "(", open + 1, close, max);
}

if (close < open) {
backtrack(result, current + ")", open, close + 1, max);
}
}
}

Submission at 2024-08-22 12:59:33

import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine().trim());

List<String> result = genParen(n);

System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("\"" + result.get(i) + "\"");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<String> genParen(int n) {
List<String> result = new ArrayList<>();
backtrack(result, "", 0, 0, n);
return result;
}

private static void backtrack(List<String> result, String current, int open, int close, int max) {

if (current.length() == max * 2) {
result.add(current);
return;
}

if (open < max) {
backtrack(result, current + "(", open + 1, close, max);
}

if (close < open) {
backtrack(result, current + ")", open, close + 1, max);
}
}
}

Submission at 2024-08-22 13:07:54

import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().trim().split("\\s+");
int[] nums = Arrays.stream(input).mapToInt(Integer::parseInt).toArray();

List<List<Integer>> result = permute(nums);

System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("[");
for (int j = 0; j < result.get(i).size(); j++) {
System.out.print(result.get(i).get(j));
if (j < result.get(i).size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
List<Integer> current = new ArrayList<>();
boolean[] used = new boolean[nums.length];
backtrack(result, current, nums, used);
return result;
}

private static void backtrack(List<List<Integer>> result, List<Integer> current, int[] nums, boolean[] used) {

if (current.size() == nums.length) {
result.add(new ArrayList<>(current));
return;
}

for (int i = 0; i < nums.length; i++) {
if (used[i]) continue;

current.add(nums[i]);
used[i] = true; // Mark as used
backtrack(result, current, nums, used); // Recur to build permutations
current.remove(current.size() - 1); // Backtrack: remove last added number
used[i] = false;
}
}
}

Submission at 2024-08-22 13:09:46

import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().trim().split("\\s+");
int[] nums = Arrays.stream(input).mapToInt(Integer::parseInt).toArray();

List<List<Integer>> result = permute(nums);

System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("[");
for (int j = 0; j < result.get(i).size(); j++) {
System.out.print(result.get(i).get(j));
if (j < result.get(i).size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
List<Integer> current = new ArrayList<>();
boolean[] used = new boolean[nums.length];
backtrack(result, current, nums, used);
return result;
}

private static void backtrack(List<List<Integer>> result, List<Integer> current, int[] nums, boolean[] used) {

if (current.size() == nums.length) {
result.add(new ArrayList<>(current));
return;
}

for (int i = 0; i < nums.length; i++) {
if (used[i]) continue;

current.add(nums[i]);
used[i] = true; // Mark as used
backtrack(result, current, nums, used); // Recur to build permutations
current.remove(current.size() - 1); // Backtrack: remove last added number
used[i] = false;
}
}
}

Submission at 2024-08-22 13:10:05

import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().trim().split("\\s+");
int[] nums = Arrays.stream(input).mapToInt(Integer::parseInt).toArray();

List<List<Integer>> result = permute(nums);

System.out.print("[");
for (int i = 0; i < result.size(); i++) {
System.out.print("[");
for (int j = 0; j < result.get(i).size(); j++) {
System.out.print(result.get(i).get(j));
if (j < result.get(i).size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
if (i != result.size() - 1) {
System.out.print(",");
}
}
System.out.print("]");
}

public static List<List<Integer>> permute(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
List<Integer> current = new ArrayList<>();
boolean[] used = new boolean[nums.length];
backtrack(result, current, nums, used);
return result;
}

private static void backtrack(List<List<Integer>> result, List<Integer> current, int[] nums, boolean[] used) {

if (current.size() == nums.length) {
result.add(new ArrayList<>(current));
return;
}

for (int i = 0; i < nums.length; i++) {
if (used[i]) continue;

current.add(nums[i]);
used[i] = true; // Mark as used
backtrack(result, current, nums, used); // Recur to build permutations
current.remove(current.size() - 1); // Backtrack: remove last added number
used[i] = false;
}
}
}

Submission at 2024-08-23 08:39:07

#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
int arr[n];
int cnt=0;
for(int i=0;i<n;i++){
cin>>arr[i];
if(arr[i]%2==0){
cnt++;
}
}
cout<<cnt;
return 0;
}

Submission at 2024-08-23 08:43:55

#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
char arr[n];
int cnt=0;
for(int i=0;i<n;i++){
cin>>arr[i];
if(arr[i].size()%2==0){
cnt++;
}
}
cout<<cnt;
return 0;
}

Submission at 2024-08-23 08:48:35

#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
string arr[n];
int cnt=0;
for(int i=0;i<n;i++){
cin>>arr[i];
if(arr[i].size()%2==0){
cnt++;
}
}
cout<<cnt;
return 0;
}

Submission at 2024-08-23 08:49:54

#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
string arr[n];
int cnt=0;
for(int i=0;i<n;i++){
cin>>arr[i];
if(arr[i].size()%2==0){
cnt++;
}
}
cout<<cnt;
return 0;
}

Submission at 2024-08-29 12:17:07

// Write the code from scratch, no boilerplate is required
#include<iostream>
#include <algorithm>
using namespace std;

int main(){
int n,m,flag=0;
cin>>n>>m;
if(n==m && (n>=1 && n<=100000) && (m>=1 && m<=100000)){
int arr1[n];
int arr2[m];

for(int i=0;i<n;i++){
cin>>arr1[i];
if(arr1[i]<1 || arr1[i]>1000){
cout<<"Wrong Input";
break;
}
}
for(int i=0;i<m;i++){
cin>>arr2[i];
if(arr2[i]<1 || arr2[i]>1000){
cout<<"Wrong Input";
break;
}
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
for(int i=0;i<n;i++){
if(arr1[i]!=arr2[i]){
cout<<"false";
break;
}
else{
flag+=1;
}
}


if(flag==n){
cout<<"true";
}
}
else{
cout<<"Length not same";
}
}

Submission at 2024-08-29 12:24:07

// Write the code from scratch, no boilerplate is required
#include<iostream>
#include <algorithm>
using namespace std;

int main(){
int n,m,flag=0;
cin>>n>>m;
if(n==m && (n>=1 && n<=100000) && (m>=1 && m<=100000)){
int arr1[n];
int arr2[m];

for(int i=0;i<n;i++){
cin>>arr1[i];
if(arr1[i]<1 || arr1[i]>1000){
cout<<"Wrong Input";
break;
}
}
for(int i=0;i<m;i++){
cin>>arr2[i];
if(arr2[i]<1 || arr2[i]>1000){
cout<<"Wrong Input";
break;
}
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
for(int i=0;i<n;i++){
if(arr1[i]!=arr2[i]){
cout<<"false";
break;
}
else{
flag+=1;
}
}


if(flag==n){
cout<<"true";
}
}
else{
cout<<"Length not same";
}
}

Submission at 2024-08-29 12:25:33

// Write the code from scratch, no boilerplate is required
#include<iostream>
#include <algorithm>
using namespace std;

int main(){
int n,m,flag=0;
cin>>n;
cin>>m;
if(n==m && (n>=1 && n<=100000) && (m>=1 && m<=100000)){
int arr1[n];
int arr2[m];

for(int i=0;i<n;i++){
cin>>arr1[i];
if(arr1[i]<1 || arr1[i]>1000){
cout<<"Wrong Input";
break;
}
}
for(int i=0;i<m;i++){
cin>>arr2[i];
if(arr2[i]<1 || arr2[i]>1000){
cout<<"Wrong Input";
break;
}
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
for(int i=0;i<n;i++){
if(arr1[i]!=arr2[i]){
cout<<"false";
break;
}
else{
flag+=1;
}
}


if(flag==n){
cout<<"true";
}
}
else{
cout<<"Length not same";
}
}

Submission at 2024-08-29 12:26:50

// Write the code from scratch, no boilerplate is required
#include<iostream>
#include <algorithm>
using namespace std;

int main(){
int n,m,flag=0;
cin>>n;
cin>>m>>endl;
if(n==m && (n>=1 && n<=100000) && (m>=1 && m<=100000)){
int arr1[n];
int arr2[m];

for(int i=0;i<n;i++){
cin>>arr1[i];
if(arr1[i]<1 || arr1[i]>1000){
cout<<"Wrong Input";
break;
}
}
cout>>endl;
for(int i=0;i<m;i++){
cin>>arr2[i];
if(arr2[i]<1 || arr2[i]>1000){
cout<<"Wrong Input";
break;
}
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
for(int i=0;i<n;i++){
if(arr1[i]!=arr2[i]){
cout<<"false";
break;
}
else{
flag+=1;
}
}


if(flag==n){
cout<<"true";
}
}
else{
cout<<"Length not same";
}
}

Submission at 2024-08-29 12:27:39

// Write the code from scratch, no boilerplate is required
#include<iostream>
#include <algorithm>
using namespace std;

int main(){
int n,m,flag=0;
cin>>n;
cin>>m;
if(n==m && (n>=1 && n<=100000) && (m>=1 && m<=100000)){
int arr1[n];
int arr2[m];

for(int i=0;i<n;i++){
cin>>arr1[i];
if(arr1[i]<1 || arr1[i]>1000){
cout<<"Wrong Input";
break;
}
}

for(int i=0;i<m;i++){
cin>>arr2[i];
if(arr2[i]<1 || arr2[i]>1000){
cout<<"Wrong Input";
break;
}
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
for(int i=0;i<n;i++){
if(arr1[i]!=arr2[i]){
cout<<"false";
break;
}
else{
flag+=1;
}
}


if(flag==n){
cout<<"true";
}
}
else{
cout<<"Length not same";
}
}

Submission at 2024-08-29 12:28:22

// Write the code from scratch, no boilerplate is required
#include<iostream>
#include <algorithm>
using namespace std;

int main(){
int n,m,flag=0;
cin>>n;
cin>>m;
if(n==m && (n>=1 && n<=100000) && (m>=1 && m<=100000)){
int arr1[n];
int arr2[m];

for(int i=0;i<n;i++){
cin>>arr1[i];
if(arr1[i]<1 || arr1[i]>1000){
cout<<"false";
break;
}
}

for(int i=0;i<m;i++){
cin>>arr2[i];
if(arr2[i]<1 || arr2[i]>1000){
cout<<"false";
break;
}
}
sort(arr1,arr1+n);
sort(arr2,arr2+n);
for(int i=0;i<n;i++){
if(arr1[i]!=arr2[i]){
cout<<"false";
break;
}
else{
flag+=1;
}
}


if(flag==n){
cout<<"true";
}
}
else{
cout<<"false";
}
}

Submission at 2024-08-29 12:34:47

#include<iostream>
using namespace std;

int main(){
int n,sum=0;
cin>>n;
for(int i=1;i<=n;i++){
if(i%3==0 || i%5==0 || i%7==0){
sum+=i;
}
}
cout<<sum;
}

Submission at 2024-08-29 12:45:20

// Write Code from Scratch
#include<iostream>
using namespace std;

int main(){
int n,m;
cin>>n;
cin>>m;
int arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<arr[j][i]<<" ";
}
cout<<endl;
}
}

Submission at 2024-08-29 13:11:29

// Write Code from Scratch
#include<iostream>
using namespace std;

int main(){
int n,m;
cin>>n;
cin>>m;
int arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<arr[j][i]<<" ";
}
cout<<endl;
}
}

Submission at 2024-08-29 13:26:28

#include<iostream>
using namespace std;

int main(){
int n,k;
cin>>n;
cin>>k;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int out=(arr[k-2]+arr[k-1])/2;
cout<<out;
}

Submission at 2024-08-29 14:32:33

#include<iostream>
using namespace std;

int main(){
int n,k;
cin>>n;
cin>>k;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int m=1;
int arr2[arr[n-1]];
int l=0;
for(int i=0;i<n;i++){
for(int j=m;j<arr[i];j++){
arr2[l]=j;
l++;

}
m=arr[i]+1;
}
cout<<arr2[k-1];

}

Submission at 2024-08-29 14:33:40

#include<iostream>
using namespace std;

int main(){
int n,k;
cin>>n;
cin>>k;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int m=1;
int arr2[arr[n-1]];
int l=0;
for(int i=0;i<n;i++){
for(int j=m;j<arr[i];j++){
arr2[l]=j;
l++;

}
m=arr[i]+1;
}
cout<<arr2[k-1];

}

Submission at 2024-08-29 14:34:04

#include<iostream>
using namespace std;

int main(){
int n,k;
cin>>n;
cin>>k;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int m=1;
int arr2[arr[n-1]];
int l=0;
for(int i=0;i<n;i++){
for(int j=m;j<arr[i];j++){
arr2[l]=j;
l++;

}
m=arr[i]+1;
}
cout<<arr2[k-1];

}

Submission at 2024-08-29 14:34:36

#include<iostream>
using namespace std;

int main(){
int n,k;
cin>>n;
cin>>k;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int m=1;
int arr2[arr[n-1]];
int l=0;
for(int i=0;i<n;i++){
for(int j=m;j<arr[i];j++){
arr2[l]=j;
l++;

}
m=arr[i]+1;
}
cout<<arr2[k-1];

}

Submission at 2024-08-29 14:38:59

#include <iostream>
using namespace std;

int findKthPositive(int arr[], int n, int k) {
int missing_count = 0;
int current = 1;
int i = 0;

while (missing_count < k) {
if (i < n && arr[i] == current) {

i++;
} else {

missing_count++;
}


if (missing_count == k) {
return current;
}

current++;
}

return current - 1;
}

int main() {
int n, k;
cin >> n >> k;

int arr[n];
for

Submission at 2024-08-29 14:40:33

#include<iostream>
using namespace std;

int main(){
int n,k;
cin>>n;
cin>>k;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
int m=1;
int arr2[arr[n-1]];
int l=0;
for(int i=0;i<n;i++){
for(int j=m;j<arr[i];j++){
arr2[l]=j;
l++;

}
m=arr[i]+1;
}
cout<<arr2[k-1];

}

Submission at 2024-08-29 15:05:04

#include <iostream>
using namespace std;

int findKthPositive(int arr[], int n, int k) {
int missing_count = 0;
int current = 1;
int i = 0;

while (missing_count < k) {
if (i < n && arr[i] == current) {
// If the current number is in the array, skip it
i++;
} else {
// If the current number is missing, increment the missing count
missing_count++;
}

// If we've found the k-th missing number, return it
if (missing_count == k) {
return current;
}

current++;
}

return current - 1;
}

int main() {
int n, k;
cin >> n >> k;

int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}

int result = findKthPositive(arr, n, k);
cout << result << endl;

return 0;
}

Submission at 2024-08-29 15:05:14

#include <iostream>
using namespace std;

int findKthPositive(int arr[], int n, int k) {
int missing_count = 0;
int current = 1;
int i = 0;

while (missing_count < k) {
if (i < n && arr[i] == current) {
// If the current number is in the array, skip it
i++;
} else {
// If the current number is missing, increment the missing count
missing_count++;
}

// If we've found the k-th missing number, return it
if (missing_count == k) {
return current;
}

current++;
}

return current - 1;
}

int main() {
int n, k;
cin >> n >> k;

int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}

int result = findKthPositive(arr, n, k);
cout << result << endl;

return 0;
}

Submission at 2024-08-29 15:08:32

#include <iostream>
using namespace std;

void spiralTraversal(int matrix[][100], int n, int m) {
int top = 0, bottom = n - 1, left = 0, right = m - 1;

while (top <= bottom && left <= right) {
// Traverse from left to right across the top row
for (int i = left; i <= right; i++) {
cout << matrix[top][i] << " ";
}
top++; // Move the top boundary down

// Traverse from top to bottom down the right column
for (int i = top; i <= bottom; i++) {
cout << matrix[i][right] << " ";
}
right--; // Move the right boundary left

if (top <= bottom) {
// Traverse from right to left across the bottom row
for (int i = right; i >= left; i--) {
cout << matrix[bottom][i] << " ";
}
bottom--; // Move the bottom boundary up
}

if (left <= right) {
// Traverse from bottom to top up the left column
for (int i = bottom; i >= top; i--) {
cout << matrix[i][left] << " ";
}
left++; // Move the left boundary right
}
}
}

int main() {
int n, m;
cin >> n >> m;

int matrix[100][100]; // Assuming maximum dimensions of 100x100 as per constraints
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> matrix[i][j];
}
}

spiralTraversal(matrix, n, m);

return 0;
}

Submission at 2024-08-29 15:10:51

#include <iostream>

using namespace std;

class Main {
public:
static int n;

static void uparr(int arr[], int size) {
if (size == 1) {
cout << arr[0] << endl;
return;
} else {
int arr1[size - 1];
for (int i = 0; i < size - 1; i++) {
arr1[i] = arr[i] + arr[i + 1];
}
uparr(arr1, size - 1);
}
}

static void main() {
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
uparr(arr, n);
}
};

int Main::n = 0;

int main() {
Main::main();
return 0;
}

Submission at 2024-08-30 05:21:00

import java.util.Scanner;
class Main {
static boolean IsPalindrome(String s1,int n,int i){
if(s1.charAt(i)!=s1.charAt(n-i-1)){
return false;
}
if(s1.charAt(i)==s1.charAt(n-i-1)){

return IsPalindrome(s1,n-1,i+1);
}
return true;

}
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=IsPalindrome(s,n,0);
if(ans=true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}

Submission at 2024-08-30 05:37:59

// write from scratch, create a function named Pow(int x, int n)
#include<iostream>
using namespace std;

int pow(int x,int n){
if(n>=0){
if(n==1){
return x;
}
return pow(x,n-1)*x;
}
else{
if(n==-1){
return x;
}
return pow(x,n+1)/x;
}

}
int main(){
int x,n;
cin>>x;
cin>>n;
int ans=pow(x,n);
cout<<ans;
}

Submission at 2024-08-30 05:44:34

// Write code from scratch
include<iostream>
using namespace std;

int main(){
int n;
int a[n];
int b[n];
int c[n];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
for(int i=0;i<n;i++){
if(a[i]>b[i]){
c[i]=a[i];
}
else{
c[i]=b[i];
}
}
for(int i=0;i<n;i++){
cout<<c[i]<<" ";
}
}

Submission at 2024-08-30 05:49:19

// Write code from scratch
#include<iostream>
using namespace std;

int main(){
int n;
int a[n];
int b[n];
int c[n];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
for(int i=0;i<n;i++){
if(a[i]>b[i]){
c[i]=a[i];
}
else{
c[i]=b[i];
}
}
for(int i=0;i<n;i++){
cout<<c[i]<<" ";
}
}

Submission at 2024-08-30 06:00:21

// Write code from scratch
import java.util.Scanner;

class Main{
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
int n;
n=sd.nextInt();
int a[]=new int[n];
int b[]=new int[n];
int c[]=new int[n];

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
for(int i=0;i<n;i++){
b[i]=sd.nextInt();
}
for(int i=0;i<n;i++){
if(a[i]>b[i]){
c[i]=a[i];
}
else{
c[i]=b[i];
}
}
for(int i=0;i<n;i++){
System.out.print(c[i]+" ");
}
}
}

Submission at 2024-08-30 06:23:28

import java.util.Scanner;
class Main {
static boolean IsPalindrome(String s1,int n,int i){
if(s1.charAt(i)!=s1.charAt(n-i-1)){
return false;
}
if(s1.charAt(i)==s1.charAt(n-i-1) && n==i){

return true;
}
return IsPalindrome(s1,n-1,i+1);


}
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=IsPalindrome(s,n,0);
System.out.println(ans);
}
}

Submission at 2024-08-30 06:25:39

import java.util.Scanner;
class Main {
static boolean IsPalindrome(String s1,int n,int i){
if(s1.charAt(i)!=s1.charAt(n-i-1)){
return false;
}
if(s1.charAt(i)==s1.charAt(n-i-1) && n==i){

return true;
}
return IsPalindrome(s1,n-1,i+1);


}
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=IsPalindrome(s,n,0);
if(ans==true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}

Submission at 2024-08-30 06:27:42

import java.util.Scanner;
class Main {
static boolean IsPalindrome(String s1,int n,int i){
if(s1.charAt(i)!=s1.charAt(n-i-1)){
return false;
}
if(s1.charAt(i)==s1.charAt(n-i-1) && (n==i || n-i==1){

return true;
}
return IsPalindrome(s1,n-1,i+1);


}
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=IsPalindrome(s,n,0);
if(ans==true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}

Submission at 2024-09-06 05:03:05

import java.util.Scanner;
class Main {
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
System.out.println(isPalindrome(n,s,0));
}

static boolean isPalindrome(int n,String s, int i){
if(i==n/2 && s.charAt(i)==s.charAt(n-i-1)){
return true;
}
if(s.charAt(i)!=s.charAt(n-i-1)){
return false;
}
return isPalindrome(n,s,i+1);
}
}

Submission at 2024-09-06 05:04:56

import java.util.Scanner;
class Main {
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=isPalindrome(n,s,0);
if(ans==true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}

static boolean isPalindrome(int n,String s, int i){
if(i==n/2 && s.charAt(i)==s.charAt(n-i-1)){
return true;
}
if(s.charAt(i)!=s.charAt(n-i-1)){
return false;
}
return isPalindrome(n,s,i+1);
}
}

Submission at 2024-09-06 05:06:32

import java.util.Scanner;
class Main {
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=isPalindrome(n,s,0);
if(ans==true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}

static boolean isPalindrome(int n,String s, int i){
if(i==n && s.charAt(i)==s.charAt(n-i-1)){
return true;
}
if(s.charAt(i)!=s.charAt(n-i-1)){
return false;
}
return isPalindrome(n-1,s,i+1);
}
}

Submission at 2024-09-06 05:08:55

import java.util.Scanner;
class Main {
public static void main (String args []) {
// Write code from scratch
Scanner sd=new Scanner(System.in);
String s=sd.next();
int n=s.length();
boolean ans=isPalindrome(n,s,0);
if(ans==true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}

static boolean isPalindrome(int n,String s, int i){
if(i==n/2 && s.charAt(i)==s.charAt(n-i-1)){
return true;
}
if(s.charAt(i)!=s.charAt(n-i-1)){
return false;
}
return isPalindrome(n,s,i+1);
}
}

Submission at 2024-09-11 05:24:38

// Write code from scratch here
import java.util.Scanner;

class Main{

public static int count(String s, char x,int i){
if(i<s.length()){
if(s.charAt(i)==x){
return count(s,x,i+1)+1;
}
return count(s,x,i+1);

}

return 0;



}
public static void main(String args[]){
Scanner sd=new Scanner(System.in);
String s=sd.next();
char x=sd.next().charAt(0);
System.out.println(count(s,x,0));
}
}

Submission at 2024-10-04 05:29:56

// Write code from scratch here
#include<iostream>
using namespace std;

int time(int a[],int n,int k){
int i=0,flag=0;
for(i=i%n;i<n && a[k]!=0;i++){
if(a[i]>0){
a[i]--;
flag++;
}

}
return flag;
}

int main(){
int n,k;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>k;
cout<<time(a,n,k);

}

Submission at 2024-10-04 05:32:16

// Write code from scratch here
#include<iostream>
using namespace std;

int time(int a[],int n,int k){
int i=0,flag=0;
for(i=0;i<n && a[k]!=0;i++){
if(a[i]>0){
a[i]--;
flag++;
}
if(i=n-1){
i=0;
}

}
return flag;
}

int main(){
int n,k;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>k;
cout<<time(a,n,k);

}

Submission at 2024-10-04 05:33:24

// Write code from scratch here
#include<iostream>
using namespace std;

int time(int a[],int n,int k){
int i=0,flag=0;
for(i=0;i<n && a[k]!=0;i++){
if(a[i]>0){
a[i]--;
flag++;
}
if(i=n-1){
i=0;
}

}
return flag;
}

int main(){
int n,k;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>k;
cout<<time(a,n,k);

}

Submission at 2024-10-04 05:41:22

// Write code from scratch here
#include<iostream>
using namespace std;

int time(int a[],int n,int k){
int i=0,flag=0,l=0;
for(i=l;i<n && a[k]!=0;l++){
if(a[i]>0){
a[i]--;
flag++;
}
i=l%n;


}
return flag;
}

int main(){
int n,k;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>k;
cout<<time(a,n,k);


}

Submission at 2024-10-04 06:20:44

// Write C++ code from scratch
#include<iostream>
#include<stdio.h>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
void arrange(char a[],int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
}
int compare(char a[],char b[]){
for(int i=0;i<7;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

char arr[7];
char arr2[7];
for(int i=0;i<7;i++){
cin>>arr[i];
}
for(int i=0;i<7;i++){
cin>>arr2[i];
}
arrange(arr,7);
arrange(arr2,7);

int ans=compare(arr,arr2);
if(ans=1){
cout<<"true";
}
else{
cout<<"false";
}
}

Submission at 2024-10-11 05:06:47

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
void arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
}
int compare(string a,string b, int n){
for(int i=0;i<7;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

string arr;
string arr2;
int n1=arr.length();
arrange(arr,n1);
arrange(arr2,n1);

int ans=compare(arr,arr2,n1);
if(ans=1){
cout<<"true";
}
else{
cout<<"false";
}
}

Submission at 2024-10-11 05:09:01

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
void arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
}
int compare(string a,string b, int n){
for(int i=0;i<7;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

string arr;
string arr2;
int n1=arr.length();
int n2=arr2.length();
if(n1==n2){
arrange(arr,n1);
arrange(arr2,n1);

int ans=compare(arr,arr2,n1);
if(ans=1){
cout<<"true";
}
else{
cout<<"false";
}
}
else{
cout<<"false";
}

}

Submission at 2024-10-11 05:11:07

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
void arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
}
int compare(string a,string b, int n){
for(int i=0;i<7;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

string arr;
string arr2;
cin>>arr;
cin>>arr2;
int n1=arr.length();
cout<<arr<<endl;
cout<<arr2<<endl;
int n2=arr2.length();
if(n1==n2){
arrange(arr,n1);
arrange(arr2,n1);

int ans=compare(arr,arr2,n1);
if(ans=1){
cout<<"true";
}
else{
cout<<"false";
}
}
else{
cout<<"false";
}

}

Submission at 2024-10-11 05:11:23

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
void arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
}
int compare(string a,string b, int n){
for(int i=0;i<7;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

string arr;
string arr2;
cin>>arr;
cin>>arr2;
int n1=arr.length();

int n2=arr2.length();
if(n1==n2){
arrange(arr,n1);
arrange(arr2,n1);

int ans=compare(arr,arr2,n1);
if(ans=1){
cout<<"true";
}
else{
cout<<"false";
}
}
else{
cout<<"false";
}

}

Submission at 2024-10-11 05:17:35

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
string arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
return a;
}
int compare(string a,string b, int n){
for(int i=0;i<7;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

string arr;
string arr2;
cin>>arr;
cin>>arr2;
int n1=arr.length();
int n2=arr2.length();
if(n1==n2){
string a=arrange(arr,n1);
string b=arrange(arr2,n1);
cout<<a<<endl;
cout<<b<<endl;
int ans=compare(a,b,n1);
if(ans=1){
cout<<"true";
}
else{
cout<<"false";
}
}

else{
cout<<"false";
}

}

Submission at 2024-10-11 05:20:54

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
string arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
return a;
}
bool compare(string a,string b, int n){
bool l=true;
for(int i=0;i<n;i++){
if(a[i]!=b[i]){
l=false;
}
}
return l;
}

int main(){

string arr;
string arr2;
cin>>arr;
cin>>arr2;
int n1=arr.length();
int n2=arr2.length();
if(n1==n2){
string a=arrange(arr,n1);
string b=arrange(arr2,n1);
cout<<a<<endl;
cout<<b<<endl;
int ans=compare(a,b,n1);
if(ans){
cout<<"true";
}
else{
cout<<"false";
}
}

else{
cout<<"false";
}

}

Submission at 2024-10-11 05:22:22

// Write C++ code from scratch
#include<iostream>
#include<string>
using namespace std;

void swap(char *x, char *y){
char t=*x;
*x=*y;
*y=t;
}
string arrange(string a,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n-1;j++){
if(a[j]>a[j+1]){
swap(&a[j],&a[j+1]);
}
}
}
return a;
}
int compare(string a,string b, int n){

for(int i=0;i<n;i++){
if(a[i]!=b[i]){
return 0;
}
}
return 1;
}

int main(){

string arr;
string arr2;
cin>>arr;
cin>>arr2;
int n1=arr.length();
int n2=arr2.length();
if(n1==n2){
string a=arrange(arr,n1);
string b=arrange(arr2,n1);
cout<<a<<endl;
cout<<b<<endl;
int ans=compare(a,b,n1);
if(ans==1){
cout<<"true";
}
else{
cout<<"false";
}
}

else{
cout<<"false";
}

}

Submission at 2024-10-25 06:10:33

// write code from scratch
#include<iostream>
using namespace std;



int main(){
char ransomNote[10];
char magazine[10];
for(int i=0;i<10;i++){
cin>>ransomNote[i];


}
for(int i=0;i<10;i++){
cin>>magazine[i];
}
char temp;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(magazine[j]>magazine[j+1]){
temp=magazine[j];
magazine[j]=magazine[j+1];
magazine[j+1]=temp;
}
}
}

for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(ransomNote[j]>ransomNote[j+1]){
temp=ransomNote[j];
ransomNote[j]=ransomNote[j+1];
ransomNote[j+1]=temp;
}
}
}
int flag=0;
for(int i=0;i<10;i++){
if(magazine[i]!=ransomNote[i]){
flag++;
}
}
if(flag!=0){
cout<<"false";
}
else{
cout<<"true";
}

}

Submission at 2024-10-25 06:55:44



/* node for linked list

class Node {
int data;
Node next;

Node(int d) {
data = d;
next = null;
}
}

*/

class Solution {
// Function to add two numbers represented by linked list.
static Node addTwoLists(Node num1, Node num2) {
// code here
// return head of sum list
int nu1=0;
int nu2=0;
int size1=1;
int size2=1;
int pow=1;
while(num1.data==0){
nu1+=(num1.data*pow);
pow*=10;
num1=num1.next;
}
pow=1;
while(num2.data==0){
nu2+=(num2.data*pow);
pow*=10;
num2=num2.next;
}
int sum1=nu1+nu2;
int n=sum1;
int size=1;
while(n/10!=0){
n=n/10;
size++;
}

num1.next.data=sum1/(10^size);
return num1.next;

}
}

Submission at 2024-11-22 05:16:36

// write code from scratch
#include<iostream>
using namespace std;

int main(){
int n,score=0,i=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int j=0;j<n;i++){
if(a[i]==a[j]){
score++;
}
}
cout<<score;
}

Submission at 2024-11-22 05:21:39

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scannew(System.in);
int n=sd.nextInt();
int a[n];
int score=0;
for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
for(int j=0;j<n;j++){
if(a[j]==a[i]){
score++;
}
}
System.out.println(score);
}
}

Submission at 2024-11-22 05:24:10

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scannew(System.in);
int n=sd.nextInt();
int a[]=new int[n];
int score=0;
for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
for(int j=0;j<n;j++){
if(a[j]==a[i]){
score++;
}
}
System.out.println(score);
}
}

Submission at 2024-11-22 05:24:39

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scannew(System.in);
int n=sd.nextInt();
int a[]=new int[n];
int score=0;
int i=0;
for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
for(int j=0;j<n;j++){
if(a[j]==a[i]){
score++;
}
}
System.out.println(score);
}
}

Submission at 2024-11-22 05:28:04

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];
int score=0;

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
int i=0;
for(int j=0;j<n;j++){
if(a[j]==a[i]){
score++;
}
}
System.out.println(score);
}
}

Submission at 2024-11-22 05:52:49

/* write code from scratch */
// write code from scratch
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int m,n,d,chk,score=0;
m=sd.nextInt();
n=sd.nextInt();
d=sd.nextInt();
int arr1[]=new int[m];
int arr2[]=new int[n];
for(int i=0;i<n;i++){
arr1[i]=sd.nextInt();
}
for(int i=0;i<n;i++){
arr2[i]=sd.nextInt();
}
for(int i=0;i<n;i++){
int fr=0;
for(int j=0;j<n;j++){
if((arr1[i]-arr[j])<0){
chk=-(arr[i]-arr[j]);
}
else{
chk=arr[i]-arr[j];
}
if((arr1[i]-arr[j])>=0){
fr++;
}

}
if(fr==n){
score++;
}
}
System.out.println(score);
}
}









/*import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];
int score=0;

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
int i=0;
for(int j=1;j<n;j++){
if(a[j]==a[i]){
score++;
}
}
System.out.println(score);
}
}

Submission at 2024-11-22 05:57:21

/* write code from scratch */
// write code from scratch
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int m,n,d,chk,score=0;
m=sd.nextInt();
n=sd.nextInt();
d=sd.nextInt();
int arr1[]=new int[m];
int arr2[]=new int[n];
for(int i=0;i<m;i++){
arr1[i]=sd.nextInt();
}
for(int i=0;i<n;i++){
arr2[i]=sd.nextInt();
}
for(int i=0;i<m;i++){
int fr=0;
for(int j=0;j<n;j++){
if((arr1[i]-arr2[j])<0){
chk=-(arr1[i]-arr2[j]);
}
else{
chk=arr1[i]-arr2[j];
}
if(chk>=d){
fr++;
}

}
if(fr==n){
score++;
}
}
System.out.println(score);
}
}










Submission at 2024-11-22 06:00:43

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];
int score=0;

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
int i=0;
for(int j=1;j<n;j++){
if(a[j]==a[i]){
score++;
}
}
System.out.println(score);
}
}

Submission at 2024-11-22 06:29:07

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];
int score=0;

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
int min=1;
int b[]=new int[n];

for(int j=1;j<n;j++){
if(a[0]==a[j]){
min++;
}
}
for(int i=0;i<n;i++){
int fr=1;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
}
}
if(fr<min){
min=fr;
}
}
int k=0;
int m=0;
for(int i=0;i<n;i++){
int fr=1;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
m=a[j];
}
if(fr==min && j==(n-1)){
b[k]=a[j];
k++;
}
}

}
int max=b[0];
for(int j=0;j<k+1;j++){
if(b[j]>max){
max=b[j];
}
}

System.out.println(max);
}
}

Submission at 2024-11-22 06:35:18

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}

int min=1;
int b[]=new int[n];

for(int j=1;j<n;j++){
if(a[0]==a[j]){
min++;
}
}
for(int i=0;i<n;i++){
int fr=0;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
}
}
if(fr<min){
min=fr;
}
}
int k=0;
int m=0;
for(int i=0;i<n;i++){
int fr=1;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
m=a[j];
}
if(fr==min && j==(n-1)){
b[k]=a[j];
k++;
}
}

}
int max=b[0];
for(int j=0;j<k+1;j++){
if(b[j]>max){
max=b[j];
}
}

System.out.println(max);
}
}

Submission at 2024-11-22 06:36:24

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}

int min=1;
int b[]=new int[n];

for(int j=1;j<n;j++){
if(a[0]==a[j]){
min++;
}
}
for(int i=0;i<n;i++){
int fr=0;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
}
}
if(fr<min){
min=fr;
}
}
int k=0;
int m=0;
for(int i=0;i<n;i++){
int fr=1;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
m=a[j];
}
if(fr==min && j==(n-1)){
b[k]=a[j];
k++;
}
}

}
int max=b[0];
for(int j=0;j<k+1;j++){
if(b[j]>max){
max=b[j];
}
}

System.out.println(max);
}
}

Submission at 2024-11-22 06:36:33

/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}

int min=1;
int b[]=new int[n];

for(int j=1;j<n;j++){
if(a[0]==a[j]){
min++;
}
}
for(int i=0;i<n;i++){
int fr=1;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
}
}
if(fr<min){
min=fr;
}
}
int k=0;
int m=0;
for(int i=0;i<n;i++){
int fr=1;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
m=a[j];
}
if(fr==min && j==(n-1)){
b[k]=a[j];
k++;
}
}

}
int max=b[0];
for(int j=0;j<k+1;j++){
if(b[j]>max){
max=b[j];
}
}

System.out.println(max);
}
}

Submission at 2024-11-22 06:43:48

/* write code from scratch */
/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int a[]=new int[n];

for(int i=0;i<n;i++){
a[i]=sd.nextInt();
}

int min=1;
int b[]=new int[n];

for(int j=1;j<n;j++){
if(a[0]==a[j]){
min++;
}
}
for(int i=0;i<n;i++){
int fr=0;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
}
}
if(fr<min){
min=fr;
}
}
int k=0;
int m=0;
for(int i=0;i<n;i++){
int fr=0;
for(int j=0;j<n;j++){
if(a[i]==a[j]){
fr++;
m=a[j];
}
if(fr==min && j==(n-1)){
b[k]=a[j];
k++;
}
}

}
int max=b[0];
for(int j=0;j<k+1;j++){
if(b[j]>max){
max=b[j];
}
}

System.out.println(max);
}
}

Submission at 2024-11-22 07:03:39

/* write code from scratch */
/* write code from scratch */
import java.util.Scanner;
class Main{
public static void main(String []args){
Scanner sd=new Scanner(System.in);
int n=sd.nextInt();
int m=(2*n)-1;
for(int i=1;i<m/2+1;i++){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
for(int i=m/2+1;i>=1;i--){
for(int j=i;j>=1;j--){
System.out.print("*");
}
System.out.println();
}
}
}

Submission at 2024-11-22 07:06:07

// Write Code From Scratch Here
#include<iostream>
using namespace std;

class main(){
int n;
cin>>n;
int arr[n];
int sum=0;
for(int i=0;i<n;i++){
cin>>arr[i];
sum=sum+arr[i];
}
cout>>sum;
}

Submission at 2024-11-22 07:09:41

// Write Code From Scratch Here
#include<iostream>
using namespace std;

class main(){
int n;
cin>>n;
int arr[n];
int sum=0;
for(int i=0;i<n;i++){
cin>>arr[i];
sum=sum+arr[i];
}
cout<<sum;
}